<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>发布微博</title>
    <!-- Bootstrap -->
    <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap.min.css" integrity="sha384-HSMxcRTRxnN+Bdg0JdbxYKrThecOKuH5zCYotlSAcp1+c8xmyTe9GYg1l9a69psu" crossorigin="anonymous">

</head>
<body>
    <div class="container">
        <form role="form" enctype="multipart/form-data" id="ddd" class="form-horizontal">
            <div class="form-group">
                <label for="" class="col-sm-2 control-label">正文</label>
                <div class="col-sm-10">
                    <input type="text" class="form-control" name="content">
                </div>
            </div>
            <div class="form-group">
                <label for="" class="col-sm-2 control-label">图片</label>
                <div class="col-sm-10">
                    <input type="file" class="" name="pic" >
                </div>
            </div>
            <div class="form-group">
                <input class="btn btn-primary center-block" type="button" value="发布" @click="send()">
            </div>
        </form>
    </div>
<!--引入axios框架-->
<script src="https://cdn.bootcdn.net/ajax/libs/axios/0.21.1/axios.min.js"></script>
<!--引入vue框架-->
<script src="https://cdn.jsdelivr.net/npm/vue@2/dist/vue.js"></script>
<script>
     let v = new Vue({
         el:"form",
         data:{

         },
         methods:{
            send:function () {
                let data = new FormData(document.querySelector("form"));
                axios.post("send",data).then(function (response) {
                    if (response.data==0){
                        alert("请先登录!");
                        location.href="/login.html";
                        return;
                    }
                    alert("发布完成!")
                    location.href="/index.html";
                })
            }
         }
     })
</script>
</body>
</html>